package com.jmp.push;

import com.jmp.api.dto.MessagePushDto;
import com.jmp.base.dto.MessagePushType;
import org.junit.Test;

public class PushClientTest3 {

    private DefaultPushClient pushClient;
//    private String cid = "487f905e83a125b65118f5b6f348365a";
    private String cid = "f1583c47f47547f20758ba092e088eca";

    public PushClientTest3() {
        OnePushProperties.OnePush onePush = new OnePushProperties.OnePush();
        onePush.setAppId("ia3mg6QHor5Y3YLfj7itZ7");
        onePush.setAppKey("by5LoDbAaKAlgesPJM10x7");
        onePush.setMasterSecret("DEXl6DB0sU5tAPAabUcPN2");
        onePush.setPackageStr("com.mushichang.huayuancrm");
        pushClient = new DefaultPushClient(onePush);
    }

    @Test
    public void send() {
        MessagePushDto messageDto = MessagePushDto.builder()
                .type(MessagePushType.CARD_UP)
                .title("test")
                .fillData(new String[]{"测试"})
                .pageParams(new String[]{MessagePushTypeEnum.CARD_UP.getPage()})
                .build();
        PushClientRequest clientRequest = PushClientRequest.builder()
                .cid(cid)
                .title(messageDto.getTitle())
                .content(messageDto.getPushContent())
                .payloadContent(messageDto.getPushPayload(pushClient.getAppId()))
                .build();
        pushClient.toOne(clientRequest);
    }

    @Test
    public void sendSingle() {
        MessagePushDto messageDto = MessagePushDto.builder()
                .type(MessagePushType.IM_CONTACT)
                .title("testa水电费20")
                .fillData(new String[]{"测试20"})
                .pageParams(new Object[]{"2380", "cjr"})
                .build();
        PushClientRequest clientRequest = PushClientRequest.builder()
                .cid(cid)
                .title(messageDto.getTitle())
                .content(messageDto.getPushContent())
                .payloadContent(messageDto.getPushPayload(pushClient.getAppId()))
                .build();
        pushClient.toOne(clientRequest);
    }

    @Test
    public void getUserStatus() {
        pushClient.getUserStatus(cid);
    }

    @Test
    public void getPushResult() {
        pushClient.getPushResult("");
    }
}